package com.nvt.core.dao;

import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nvt.core.dao.cb.CallBackHandler;
import com.nvt.core.exception.NvtBusinessException;

@Service
public class SPDAOImpl implements ISPDAO {

	@Autowired
	private DataSource dataSource;

	@Override
	public void executeSpCallback(Map<String, Object> map)
			throws NvtBusinessException {
		try {
			CallBackHandler callbackHandler = new CallBackHandler(dataSource,
					(String) map.get("spName"));

			callbackHandler.executeCallBack(map);
		} catch (NvtBusinessException e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

}
